<?php
include'cnx.php';

class contenido
{







function temas()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = " SELECT  * FROM tb_temas order by nombre asc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function cnox()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
		
		 			return true;
	   }
	   else
	   {
		   return false;
		   }
}
/////////

function ingConcep($txfec,$txconc,$txtit,$txtit2,$txd,$txv,$valid,$im)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "insert into tb_concepto(post_date,concepto,titulo,tituloc,descripcion,video,validar,imagen)values('$txfec','$txconc','$txtit','$txtit2','$txd','$txv','$valid','$im')";			
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function ing_Rel($idConc,$idTem,$ord)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "insert into tb_relac_tema(id_concep,id_tema,term_order)values('$idConc','$idTem','$ord')";			
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function idMax()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT MAX(id_concep) as id FROM tb_concepto ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}
function concepto_det($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_concepto where id_concep='$codV'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function concepto_actual($tit,$conten,$imgx,$cod,$url,$des)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_concepto set titulo='$tit',concepto='$conten',imagen='$imgx',video='$url',descripcion='$des' where id_concep ='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}
//  Recursos  :

function recursos()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = " SELECT  * FROM tb_recurso order by titulo asc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function ListConcepto()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = " SELECT  * FROM tb_concepto where validar='si' order by titulo asc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function ingRecur($txfec,$txconc,$txtit,$txtit2,$txclas,$valid,$imgx)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "insert into tb_recurso(post_date,concepto,titulo,tituloc,class,validar,imagen)values('$txfec','$txconc','$txtit','$txtit2','$txclas','$valid','$imgx')";			
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function recurso_det($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_recurso where id_recurso='$codV'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}
function recurso_actual($tit,$conten,$imag,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_recurso set titulo='$tit',concepto='$conten',imagen='$imag' where id_recurso ='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function Imagenes()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = " SELECT  * FROM tb_imagenes ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}



function Edit_imag($tit,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_imagenes set imagen='$tit' where idimag ='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function LisImagenes()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT tc.id_concep as id,tc.titulo as titulo, tc.imagen as imag,ti.id as reg   from tb_concepto tc inner join tb_himg ti on tc.id_concep =ti.id_concep ";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function edit_hom($idConc,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_himg set id_concep='$idConc' where id='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function edit_homC($img,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_concepto set imagen='$img' where id_concep='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountN($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '3' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountV($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '78' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountW($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '6' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function Det_relac($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_relac_tema where id_concep='$codV' order by id_tema desc limit 0,1";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temasRest()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_temas where id_tema not like '78' and  id_tema not like '83' order by nombre asc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function Act_TemPost($codP,$codT,$conN)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_relac_tema set id_tema='$conN' where id_concep ='$codP' and id_tema='$codT'";
			
			 
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function Elim_TemPost($codP,$codT)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="delete from tb_relac_tema where id_concep ='$codP' and id_tema='$codT'";
			
			  
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function temasAgr()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = " SELECT  * FROM tb_temas where id_tema not like '78' and  id_tema not like '83' order by nombre asc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function Act_lib($tit,$url,$id)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_libros set titulo='$tit',tituloc='$url' where id_recurso ='$id'";
			
			 
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function ingLib($txfec,$txconc,$txtit,$txtit2,$txclas,$valid,$imgx)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "insert into tb_libros(post_date,concepto,titulo,tituloc,class,validar,imagen)values('$txfec','$txconc','$txtit','$txtit2','$txclas','$valid','$imgx')";			
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}


function libro_det($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_libros where id_recurso='$codV'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}







}
?>
